package be.kdg.bombermanunlimited.server.network.interfaces;

import java.rmi.Remote;
import java.rmi.RemoteException;

import be.kdg.bombermanunlimited.client.network.listeners.IRingServerListener;

/**
 * Manager interface die door de client gebruikt kan worden.
 * @author Philip
 *
 */
public interface INetworkManager extends Remote {

	/**
	 * Let the manager know that you couldn't connect to a node
	 * 
	 * @param destNode
	 *            The node with which you can't connect
	 * @throws RemoteException
	 */
	void cantConnect(String srcNode, int srcPort, String dstNode, int dstPort)
			throws RemoteException;

	/**
	 * Let the manager know that you've lost the connection to a node
	 * 
	 * @param destNode
	 *            Ip of the remote host
	 * @throws RemoteException
	 */
	void connectionLost(String sourceNode, int sourcePort, String destNode,
			int destPort) throws RemoteException;

	/**
	 * Register your ip address so the manager knows you are there. If the ip address and port combination already exists, the existing in the ring
	 * will get removed and this new one gets added. This because this means that you got disconnected for some strange reason.
	 * 
	 * @param ip
	 *            Your WAN ip-address
	 * @param listener
	 *            You also need to register a listener, so the server can
	 *            contact you if you must create a connection
	 * @param port
	 *            The port which is used by the Ringnetwork
	 * @return true if succesfull registered
	 * @throws RemoteException
	 */
	void registerNode(String ip, int port, IRingServerListener listener)
			throws RemoteException;

	/**
	 * Remove yourself as node
	 * 
	 * @param listener
	 *            the listener you've registered
	 * @throws RemoteException
	 */
	void removeNode(String ip, int port, IRingServerListener listener)
			throws RemoteException;
}
